<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/mzw/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/mzw/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/mzw/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/mzw/images/logo.svg" color="#222">

<link rel="stylesheet" href="/mzw/css/main.css">


<link rel="stylesheet" href="/mzw/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"zhihuai-yixing.gitee.io","root":"/mzw/","scheme":"Gemini","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="第一章 Java虚拟机它在哪？我们初学Java的时候和JVM的关系，就像三国时期，准备要大干一番事业的刘备和还未出世的诸葛亮一样，只听说过它，但是它在哪里呢？当然不在南阳诸葛庐，哈哈。 首先我们先找到我们JDK的安装位置">
<meta property="og:type" content="article">
<meta property="og:title" content="Java虚拟机学习笔记">
<meta property="og:url" content="https://zhihuai-yixing.gitee.io/mzw/2021/12/01/Java%E8%99%9A%E6%8B%9F%E6%9C%BA/index.html">
<meta property="og:site_name" content="志怀逸兴">
<meta property="og:description" content="第一章 Java虚拟机它在哪？我们初学Java的时候和JVM的关系，就像三国时期，准备要大干一番事业的刘备和还未出世的诸葛亮一样，只听说过它，但是它在哪里呢？当然不在南阳诸葛庐，哈哈。 首先我们先找到我们JDK的安装位置">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://pic2.zhimg.com/80/v2-78ec22d4d972815bfe3bdcaa442d0f91_720w.jpg">
<meta property="og:image" content="https://pic2.zhimg.com/80/v2-78ec22d4d972815bfe3bdcaa442d0f91_720w.jpg">
<meta property="og:image" content="https://images2018.cnblogs.com/blog/1304923/201803/1304923-20180329120738841-1107069261.png">
<meta property="article:published_time" content="2021-12-01T07:36:43.572Z">
<meta property="article:modified_time" content="2021-12-01T07:43:04.884Z">
<meta property="article:author" content="邓紫棋的小迷帝">
<meta property="article:tag" content="Java虚拟机">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://pic2.zhimg.com/80/v2-78ec22d4d972815bfe3bdcaa442d0f91_720w.jpg">

<link rel="canonical" href="https://zhihuai-yixing.gitee.io/mzw/2021/12/01/Java%E8%99%9A%E6%8B%9F%E6%9C%BA/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>Java虚拟机学习笔记 | 志怀逸兴</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/mzw/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">志怀逸兴</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">俱怀逸兴壮思飞, 欲上青天揽明月</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/mzw/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/mzw/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/mzw/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/mzw/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/mzw/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://zhihuai-yixing.gitee.io/mzw/2021/12/01/Java%E8%99%9A%E6%8B%9F%E6%9C%BA/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/mzw/images/avatar.gif">
      <meta itemprop="name" content="邓紫棋的小迷帝">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="志怀逸兴">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          Java虚拟机学习笔记
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              

              <time title="创建时间：2021-12-01 15:36:43 / 修改时间：15:43:04" itemprop="dateCreated datePublished" datetime="2021-12-01T15:36:43+08:00">2021-12-01</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/mzw/categories/Java%E8%99%9A%E6%8B%9F%E6%9C%BA/" itemprop="url" rel="index"><span itemprop="name">Java虚拟机</span></a>
                </span>
            </span>

          
            <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv" style="display: none;">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span id="busuanzi_value_page_pv"></span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h2 id="第一章-Java虚拟机它在哪？"><a href="#第一章-Java虚拟机它在哪？" class="headerlink" title="第一章 Java虚拟机它在哪？"></a>第一章 Java虚拟机它在哪？</h2><p>我们初学Java的时候和JVM的关系，就像三国时期，准备要大干一番事业的刘备和还未出世的诸葛亮一样，只听说过它，但是它在哪里呢？当然不在南阳诸葛庐，哈哈。</p>
<p>首先我们先找到我们JDK的安装位置</p>
<span id="more"></span>

<img src="https://pic2.zhimg.com/80/v2-78ec22d4d972815bfe3bdcaa442d0f91_720w.jpg" alt="img" style="zoom:80%;">

<ul>
<li><strong>bin文件夹：</strong>最主要的是编译器(javac.exe)。</li>
<li><strong>include文件夹：</strong>Java和JVM交互用的头文件（具体是干什么的还没研究..<strong>.)</strong></li>
<li><strong>jre文件夹：</strong>jre（Java Runtime Environment）<strong>Java运行环境</strong></li>
<li><strong>lib文件夹：</strong>Java基础类库（支持JDK的工具和实用程序的非核心类。）</li>
</ul>
<p>可是我们要找的JVM还不在这里，还需要深挖一下，往下看！</p>
<img src="https://pic2.zhimg.com/80/v2-78ec22d4d972815bfe3bdcaa442d0f91_720w.jpg" alt="img" style="zoom:80%;">

<p>在JDK的安装目录下有一个jre目录，里面有两个文件夹bin和lib，在这里**可以认为bin里的就是jvm，lib中则是jvm工作所需要的类库，而jvm和 lib合起来就称为jre。</p>
<p><strong>JVM的面试题：JDK、JRE、JVM三者的联系与区别？</strong></p>
<h2 id="第二章-Java虚拟机的主要组成部分？及其作用？"><a href="#第二章-Java虚拟机的主要组成部分？及其作用？" class="headerlink" title="第二章 Java虚拟机的主要组成部分？及其作用？"></a>第二章 Java虚拟机的主要组成部分？及其作用？</h2><p>Java虚拟机主要是一下四个部分：</p>
<p><strong>类加载器（ClassLoader）</strong>:加载类文件到内存。Class loader只管加载，只要符合文件结构就加载，至于能否运行，它不负责，那是有Exectution Engine 负责的。</p>
<p><strong>运行时数据区（Runtime Data Area）</strong>:JVM的内存</p>
<p><strong>执行引擎（Execution Engine）</strong>:也叫解释器，负责解释命令，交由操作系统执行。</p>
<p><strong>本地库接口（Native Interface）</strong>:本地接口的作用是融合不同的语言为java所用</p>
<img src="https://images2018.cnblogs.com/blog/1304923/201803/1304923-20180329120738841-1107069261.png" alt="二、运行时JVM结构组成及作用_alexfan2009的博客-程序员宝宝- 程序员宝宝" style="zoom:80%;">




<p>各组件的作用：首先通过类加载器（ClassLoader）会把 Java 代码转换成字节码，运行时数据区（Runtime Data Area）再把字节码加载到内存中，而字节码文件只是 JVM 的一套指令集规范，并不能直接交给底层操作系统去执行，因此需要特定的命令解析器执行引擎（Execution Engine），将字节码翻译成底层系统指令，再交由 CPU 去执行，而这个过程中需要调用其他语言的本地库接口（Native Interface）来实现整个程序的功能。</p>
<h2 id="第三章-谈对运行时数据区-JVM内存区域-的理解"><a href="#第三章-谈对运行时数据区-JVM内存区域-的理解" class="headerlink" title="第三章 谈对运行时数据区(JVM内存区域)的理解"></a>第三章 谈对运行时数据区(JVM内存区域)的理解</h2>
    </div>

    
    
    

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/mzw/tags/Java%E8%99%9A%E6%8B%9F%E6%9C%BA/" rel="tag"># Java虚拟机</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/mzw/2021/11/30/04.%E6%B7%B1%E5%85%A5%E6%B5%85%E5%87%BA%E7%B4%A2%E5%BC%95%EF%BC%88%E4%B8%8A%EF%BC%89/" rel="prev" title="MySQL学习笔记">
      <i class="fa fa-chevron-left"></i> MySQL学习笔记
    </a></div>
      <div class="post-nav-item">
    <a href="/mzw/2021/12/02/01.%E4%B8%80%E6%9D%A1SQL%E6%9F%A5%E8%AF%A2%E8%AF%AD%E5%8F%A5%E6%98%AF%E5%A6%82%E4%BD%95%E6%89%A7%E8%A1%8C%E7%9A%84%EF%BC%9F/" rel="next" title="MySQL学习笔记">
      MySQL学习笔记 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%AC%AC%E4%B8%80%E7%AB%A0-Java%E8%99%9A%E6%8B%9F%E6%9C%BA%E5%AE%83%E5%9C%A8%E5%93%AA%EF%BC%9F"><span class="nav-number">1.</span> <span class="nav-text">第一章 Java虚拟机它在哪？</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%AC%AC%E4%BA%8C%E7%AB%A0-Java%E8%99%9A%E6%8B%9F%E6%9C%BA%E7%9A%84%E4%B8%BB%E8%A6%81%E7%BB%84%E6%88%90%E9%83%A8%E5%88%86%EF%BC%9F%E5%8F%8A%E5%85%B6%E4%BD%9C%E7%94%A8%EF%BC%9F"><span class="nav-number">2.</span> <span class="nav-text">第二章 Java虚拟机的主要组成部分？及其作用？</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%AC%AC%E4%B8%89%E7%AB%A0-%E8%B0%88%E5%AF%B9%E8%BF%90%E8%A1%8C%E6%97%B6%E6%95%B0%E6%8D%AE%E5%8C%BA-JVM%E5%86%85%E5%AD%98%E5%8C%BA%E5%9F%9F-%E7%9A%84%E7%90%86%E8%A7%A3"><span class="nav-number">3.</span> <span class="nav-text">第三章 谈对运行时数据区(JVM内存区域)的理解</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="邓紫棋的小迷帝"
      src="/mzw/images/avatar.gif">
  <p class="site-author-name" itemprop="name">邓紫棋的小迷帝</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/mzw/archives/">
        
          <span class="site-state-item-count">6</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/mzw/categories/">
          
        <span class="site-state-item-count">3</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/mzw/tags/">
          
        <span class="site-state-item-count">3</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        <!--
-->

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">邓紫棋的小迷帝</span>
</div>

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>








      </div>
    </footer>
  </div>

  
  <script src="/mzw/lib/anime.min.js"></script>
  <script src="/mzw/lib/velocity/velocity.min.js"></script>
  <script src="/mzw/lib/velocity/velocity.ui.min.js"></script>

<script src="/mzw/js/utils.js"></script>

<script src="/mzw/js/motion.js"></script>


<script src="/mzw/js/schemes/pisces.js"></script>


<script src="/mzw/js/next-boot.js"></script>




  















  

  

</body>
</html>
